<?php
/**
* 名称：展会模型类。
* 描述：展会模块业务逻辑的相关程式。
*/
final class Model_Exhibition extends Model{
    /**
    * 描述：供给数据之首页合作展会。
    * @static
    * @access public
    * @return array
    */
    public static function GetDataX0001(){
        $data=array(
            'Name'=>'合作展会',
            'Link'=>Route::MakeHyperlink(':exhibition::listview'),
            'Rows'=>self::MakeLinkForDetail(self::$Database->GetAll(
                'SELECT * FROM '.self::$Database->Table('exhibition').' WHERE id in(137,143,177,178) ORDER BY datetime DESC LIMIT 0,4'
            ))
        );
        //~
        return $data;
    }

    /**
    * 描述：供给数据之内参首页展会。
    * @static
    * @access public
    * @return array
    */
    public static function GetDataX0002(){
        $data=array(
            'Name'=>'行业展会',
            'Link'=>Route::MakeHyperlink(':exhibition::listview'),
            'Rows'=>self::MakeLinkForDetail(self::$Database->GetAll(
                'SELECT * FROM '.self::$Database->Table('exhibition').' ORDER BY datetime DESC LIMIT 0,4'
            ))
        );
        //~
        return $data;
    }

    /**
    * 描述：完成数据之详细页面。
    * @static
    * @access public
    * @return array
    */
    public static function MakeLinkForDetail($data){
        $temp=array_values($data);
        if(gettype($temp[0])=='array'){
            foreach($data as &$row){
                $row['link']=Route::MakeHyperlink(':exhibition::detail',array('id'=>$row['id']));
                $row['cover']=BUILD_PATH.'/data/000/exhibition/'.$row['cover'];
                $row['industry_name']=self::$Database->GetOne(
                    'SELECT name FROM '.self::$Database->Table('exhibition_industry').' WHERE id='.$row['industry']
                );
            }
        }
        else{
            $data['link']=Route::MakeHyperlink(':exhibition::detail',array('id'=>$data['id']));
            $data['cover']=BUILD_PATH.'/data/000/exhibition/'.$data['cover'];
        }
        return $data;
    }

    /**
    * 描述：完成数据之列表页面。
    * @static
    * @access public
    * @return array
    */
    public static function MakeLinkForListview($data){
        foreach($data as &$row){
            $row['link']=Route::MakeHyperlink(':exhibition::listview',array('class'=>$row['id']));
        }
        return $data;
    }
}